/**
 * 
 */
package com.fwzc.giuseppe.activity;

import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.HashMap;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.ListView;

import com.fwzc.giuseppe.R;
import com.fwzc.giuseppe.adapter.AccountsAdapter;
import com.fwzc.giuseppe.base.BaseActivity;
import com.lidroid.xutils.view.annotation.event.OnItemClick;

/**
 * 
 * 类名称：SwitchAccountsActivity 类描述： 创建人：何琳 创建时间：2015年8月14日 下午3:37:36
 * 
 * @version
 * 
 */
public class SwitchAccountsActivity extends BaseActivity implements
		OnClickListener {

	private ListView listview;
	private AccountsAdapter mAdapter;
	private ArrayList<HashMap<String, String>> dataList = new ArrayList<HashMap<String, String>>();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_switching_accounts);

		initBar();
		initheadView();
		initView();
		initData();
	}

	private void initheadView() {
		actionbar_side_name.setText("切换账号");
		iv_actionbar_side_left.setVisibility(View.VISIBLE);
		tv_actionbar_side_right.setVisibility(View.VISIBLE);
		tv_actionbar_side_right.setTextColor(getResources().getColor(
				R.color.black_56));
		tv_actionbar_side_right.setText("添加账户");

	}

	private void initView() {
		listview = (ListView) findViewById(R.id.accounts_list);
		mAdapter = new AccountsAdapter(this, dataList);
	}

	private void initData() {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("imageUrl",
				getResources().getDrawable(R.drawable.icon_circle_msg)
						.toString());
		map.put("name", "张晓光");
		dataList.add(map);
		map = new HashMap<String, String>();
		map.put("imageUrl",
				getResources().getDrawable(R.drawable.icon_circle_msg01)
						.toString());
		map.put("name", "张晓明");
		dataList.add(map);
		listview.setAdapter(mAdapter);
		listview.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {

			}
		});

		iv_actionbar_side_left.setOnClickListener(this);
		tv_actionbar_side_right.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		if (v == iv_actionbar_side_left) {
			finish();
		} else if (v == tv_actionbar_side_right) {
			Intent intent = new Intent(SwitchAccountsActivity.this,
					LoginActivity.class);
			startActivity(intent);
		}

	}

}
